<?php 
echo "您是否要清空并award_items表根据config/item.php里的配置重建表数据,会导致之前数据丢失\n\n如果您确认了,请输入YES后回车,否则直接回车\n";
$sure = fread(STDIN, 3);  
if(strtoupper($sure) != 'YES'){
	die('取消执行');
}

defined('__ROOT__') or define('__ROOT__',dirname(dirname(__FILE__)));
require(__ROOT__.'/comm/mysql.php');
$items = require(__ROOT__.'/config/item.php');
$pdo->exec('TRUNCATE TABLE `award_items`');//先清空以前的数据,防止重复
$sql = 'INSERT INTO `award_items`(`item_id`) VALUES';
//$pr_total = 0;
foreach($items as $item_id=>$item){
	//$pr_total+=$item['pr'];
	for($i=0;$i<$item['num'];$i++){
		$sql .= "($item_id),";
	}
}
$sql = rtrim($sql,',');
$effect_row = $pdo->exec($sql);
echo '执行成功,插入'.$effect_row.'行';

